package com.javafactroy.kunlong.common.utils;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.stereotype.Service;

@Service
public class BeanFactoryUtils implements BeanFactoryAware {
    private BeanFactory beanFactory;

    @Override
    public void setBeanFactory(BeanFactory beanFactory) {
        this.beanFactory = beanFactory;
    }

    public <T> T getBean(String beanName) {
        return (T) beanFactory.getBean(beanName);
    }
    public <T> T getBean(Class<T> cls) {
        return (T) beanFactory.getBean(cls);
    }

    public boolean isSingleton(String var1) throws NoSuchBeanDefinitionException{
        return beanFactory.isSingleton(var1);
    }

    public boolean isPrototype(String var1) throws NoSuchBeanDefinitionException{
        return beanFactory.isPrototype(var1);
    }

}